<!DOCTYPE html>
<html>
<head>
 <link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css?v=1">
<link rel="stylesheet" href="css/member.css">
<link rel="stylesheet" href="css/order3.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<meta content="telephone=no" name="format-detection">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1,user-scalable=no">
<title>首页</title>
</head>
<body>
<!--<header class="header">
 	<div class="fix_nav">
	<div style="max-width:768px;margin:0 auto;height: 44px;position: relative;background:#000000;">
		<form action="category_list.html" method="get" id="searchform" name="searchform">
			<div class="navbar-search left-search">
					<input type="text" id="keyword" name="keyword" value="" placeholder="搜索商品" class="form-control">
			</div>
			<div class="nav-right">
				<input type="button" value="搜索" onclick="searchproduct();" class="img-responsive" style="text-align:center;background:#ccc;border-radius: 5px;border:none;height:34px;vertical-align:middle;clear:both;padding:0px;width:42px;"/>
			</div>
		</form>
	</div>
	</div>
</header> -->
<div id="wrapper">
	<div class="container">
		 <div class="row">
	        <div id="slide">
	            <div class="hd">
	                <ul><li class="on">1</li><li class="on">2</li><li class="on">3</li></ul>
	            </div>
	            <div class="bd">
	                <div class="tempWrap" style="overflow:hidden; position:relative;">
	                		<ul id="xxads" style="width: 3840px; position: relative; overflow: hidden; padding: 0px; margin: 0px; transition-duration: 200ms; transform: translateX(-768px);">
			                	  <li style="display: table-cell; vertical-align: top; width: 768px;">
			   	                    	<a href="#">
			   	                    		<img style="height: 25px; width: 25px;margin: 5rem 48%;" src="images/loading.gif" alt="加载中" ppsrc="img/0da8eb94-0159-4700-a6a5-bc007da5a853.jpg">
			   	                    	</a>
			   	                    </li>
		                	</ul>
	                </div>
	            </div>
	        </div>
	    </div>
	<div class="row category" id="xxProductCategory">
		<a href="#" >
		   	 <img style="height: 25px; width: 25px;margin: 1.5rem 47%;" src="images/loading.gif" alt="加载中" ppsrc="img/0da8eb94-0159-4700-a6a5-bc007da5a853.jpg">
		 </a>
    </div>
	<div class="row" id="xxTagProduct">
		<a href="#" >
	   		 <img style="height: 25px; width: 25px;margin: 8rem 47%;" src="images/loading.gif" alt="加载中" ppsrc="img/0da8eb94-0159-4700-a6a5-bc007da5a853.jpg">
		</a>
	</div>
</div>
	<div class="item-list tb_box container" rel="2" status="0">
			<h2 class="tab_tit">
						每日推荐</h2>
			<div class="tb_type tb_type_even clearfix" id="xxProductListPage">
		</div>
	</div>
</div>
<div style="text-align: center;" id="leadingMsg">--下拉加载...--</div>
<footer class="footer">
  <div class="foot-con">
	<div class="foot-con_2">
		<a href="index.html" class="active">
			<i class="navIcon home"></i>
			<span class="text">首页</span>
		</a>
		<a href="category.html">
			<i class="navIcon sort"></i>
			<span class="text">分类</span>
		</a>
		<a href="shopcart.html">
			<i class="navIcon shop"></i>
			<span class="text">购物车</span>		
		</a>
		<a href="./my/userhome.html" >
			<i class="navIcon member"></i>
			<span class="text">我的</span>
		</a>
	</div>
  </div>
</footer>

<script charset="utf-8" src="js/StringBuilder.js"></script>
<script charset="utf-8" src="js/templeteHtml.js"></script>
<script charset="utf-8" src="js/common.js"></script>
<script charset="utf-8" src="js/jquery.min.js"></script>
<!-- cookie操作js -->
<script charset="utf-8" src="js/global.js"></script>
<!-- bootstrap -->
<script charset="utf-8" src="js/bootstrap.min.js"></script>
<!-- 登录信息获取js -->
<script charset="utf-8" src="js/wxLoginInfo.js"></script>
<script charset="utf-8" src="js/TouchSlide.js"></script>
	<script type="text/javascript">
		InitTouchSlide();
		function InitTouchSlide(){
			TouchSlide({
				slideCell:"#slide",
				titCell:".hd ul", //开启自动分页 autoPage:true ，此时设置 titCell 为导航元素包裹层
				mainCell:".bd ul",
				effect:"left",
				autoPlay:true,//自动播放
				autoPage:true, //自动分页
				switchLoad:"_src" //切换加载，真实图片路径为"_src"
			});
		}
	
</script>
	<script type="text/javascript">
		loginInfo(function(userInfo){
			console.log(userInfo);
		})
	$.get("./home",{},function(ret){
		if(ret&&ret.code==200){
			var xxads=ret.data.xxads;
			var xxProductCategorys=ret.data.xxProductCategory;
			var xxTagsLists=ret.data.xxTagsList;
			var xxProductListPage=ret.data.xxProductListPage.list;
			//首页广告图片展示
			if(xxads!=undefined&&xxads.length>0){
				var xxadsListsHtml="";
				if(xxads!=undefined&&xxads.length>0){
					for(var i=0;i<xxads.length;i++){
						xxadsListsHtml+= String.formatmodel(templete.getXxAds(), xxads[i]);
					}
				}
				$("#xxads").html(xxadsListsHtml);
				InitTouchSlide();
				var xxProductCategorysHtml="";	
				if(xxProductCategorys!=undefined&&xxProductCategorys.length>0){
					for(var i=0;i<xxProductCategorys.length;i++){
						xxProductCategorysHtml+=String.formatmodel(templete.getXxProductCategoryTeml(), xxProductCategorys[i]);
					}
				}
				$("#xxProductCategory").html(xxProductCategorysHtml);
				}

				$("#xxTagProduct").html("");
			//第二栏目区域展示
			if(xxTagsLists!=undefined&&xxTagsLists.length>0){	
				for(var i=0;i<xxTagsLists.length;i++){
					var xxTagProductHtml='<div class="tb_box" >';
					xxTagProductHtml+=String.formatmodel(templete.getXxTagProductHraderTeml(), xxTagsLists[i]);
					xxTagProductHtml+='<div class="tb_type clearfix">';
					var xxProductLists=xxTagsLists[i].xxProductList;
					for(var j=0;j<xxProductLists.length;j++){
						xxTagProductHtml+=String.formatmodel(templete.getXxTagProductTeml(), xxProductLists[j]);
					}
					if(xxProductLists.length==0||xxProductLists[0]==null){
						xxTagProductHtml=""
					}else{
						xxTagProductHtml+"</div></div>"
					}
					$("#xxTagProduct").append(xxTagProductHtml);
				}
			}
			//设置样式
			setTagProductCss();
			//每日推荐展示
			if(xxProductListPage!=undefined&&xxProductListPage.length>0){
				for(var i=0;i<xxProductListPage.length;i++){
					$("#xxProductListPage").append(String.formatmodel(templete.getXxDayProductTeml(),xxProductListPage[i]));
				}
			}
		}else{
			alert("请检查网络设置!");
		}
	},'json');
	function setTagProductCss(){
		var div=$("#xxTagProduct .tb_box");
		for(var i=0;i<div.length;i++){
			var imgdiv=$(div[i]).find("img");
			var len=imgdiv.length;
			imgdiv[1].style.height="10rem"
			imgdiv[0].style.height="20rem"
			imgdiv[2].style.height="10rem"
		}
	};
	
</script>
<script type="text/javascript">
$(document).ready(function(){
	$("#slide img").each(function(){
	var img_src=$(this).attr("_src");
	$(this).attr("src",img_src);
	});
});

function searchproduct(){
	   var keyword = document.getElementById("keyword").value;
	   if(keyword == undefined || keyword==null ||keyword ==""){
	     alert("请输入搜索关键字！");
	     return false;
	   }
	   document.getElementById("searchform").submit();
	}
</script>
<script type="text/javascript">  
//首先，窗口绑定事件scroll  
var page=2;
var rows=10;
$(window).bind("scroll",function() {  
	$("#leadingMsg").html("下拉加载...")
    // 判断窗口的滚动条是否接近页面底部，这里的20可以自定义  
    if ($(document).scrollTop() + $(window).height() == $(document).height() ) {  
       //没有写ajax的调用，直接触发了链接的click事件。
       $("#leadingMsg").html("--拼命加载中...--");
		// 异步加载数据
         $.get("./product/listPage",{page:page,rows:rows},function(ret){
				if(ret&&ret.data&&ret.data.list.length>0){
					var xxProductListPage=ret.data.list;
					if(xxProductListPage!=undefined&&xxProductListPage.length>0){
						for(var i=0;i<xxProductListPage.length;i++){
							$("#xxProductListPage").append(String.formatmodel(templete.getXxDayProductTeml(),xxProductListPage[i]));
						}
					}
					page+=1;
				}else{
					$("#leadingMsg").html("更多商品正在努力备货中,敬请期待!")
				}
          })
    }
})  
$(document).ready(function(){  
    $('body,html').animate({scrollTop:0});   
});  
</script>  
</body>
</html>

